We don't always know why hard times come to us; sometimes they're simply a result of living in an imperfect world -- a world corrupted by sin. Job (who knew what it was to suffer) declared, "Man is born to trouble as surely as sparks fly upward" (Job 5:7).
But when hard times do happen, by faith we know that God is still in control (even if it doesn't seem like it), and we can turn to Him for the strength and encouragement we need. Over the years, I've found that people often react to hard times in one of two ways. Some get angry at God and turn against Him -- which is tragic, because they're cutting themselves off from their only source of lasting help. Others, however, turn to God and find comfort and strength in Him.
Why does God allow hard times to happen to us? Sometimes we bring them on ourselves, because we've made unwise decisions or disobeyed God's moral laws. When that's the case, we need to repent and seek the forgiveness that can only come through Christ.
But even if we don't know the reason, God still loves us and wants to draw us closer to Himself. The Bible says we can even "rejoice in our sufferings, because we know that suffering produces perseverance; perseverance, character; and character hope" (Romans 5:3-4). When hard times come to you, turn to Christ (who suffered and died for you), and ask God to use them to strengthen your faith.