Real merit are earned by Knowledge, that is the easiest way to Knowledge. Without knowledge you can't earn merit . Getting knowledge is obtained by spending time to learn and make research , this how to alway earn merit. Seeking for knowledge always will always bring merit.
You are right on the part that knowledge is essential for obtaining merit on the forum but it should be reflected in your post and then it should be liked by some members who can then give you merit.Keep in mind the main goal is to share good information with members like someone has asked a technical question and you know the answer for the same then you should explain him in detail the process and help him and for that you can get merit from other members who liked your post.
Gaining knowledge and learning is continuous process and you need to evolve yourself with time and make quality post that don't have irrelevant information and be on topic that will help you to gain merits.It always come with time so make sure you are dedicated towards it.