There are many times in life that we wonder "why is this happening to me?" When we have struggles and hardships, we are often not able to see the overall picture. People tend to wallow in self-pity and blame Heavenly Father for everything they are going through. God really wants us to gain knowledge from these times. I have an experience where I was able to help someone because of my trials. My health has not been very good and it kept dragging out for months. There were times I wondered why Heavenly Father was not letting me know what was wrong and was letting it go on. My mother would go into my doctors appointments with me and they would ask her if she had had her gallbladder out, because that was around where I was experiencing pain. She told them no each time. Later she was experiencing pain and, because she saw that doctors weren't getting anywhere with me, she went into the ER. There, she found out that she had gallstones and would be needing to get her gallbladder out. I prayed for a long time before this, asking for answers. I believe this is one of the things I needed to learn and experience to help others.
Elder W. Mark Bassett gave a talk during the October 2016 General Conference called "For Our Spiritual Development and Learning". In his talk, he says "In order to understand the mysteries of God, or those things that can be understood only through revelation, we must follow the example of Nephi, who said, 'Being exceedingly young, nevertheless being large in stature, and also having great desires to know of the mysteries of God, wherefore, I did cry unto the Lord; and behold he did visit me, and did soften my heart that I did believe all the words which had been spoken by my father.' The Lord Himself further explained that Nephi had exercised faith, sought diligently with lowliness of heart, and kept His commandments." To put that simply, we must have a sincere desire, be humble, pray, trust in the prophet, exercise faith, seek diligently, and be obedient. Heavenly Father wants us to ask questions and gain knowledge. If we do what we are asked, we are able to learn and also see that the trials we go through are for our own growth.
Click here to read the whole talk.