Trials test faith so that it may be shown genuine, compared to gold refined by fire (1 Peter 1:6–7). Peter says this results in “praise and glory and honor” at the revelation of Jesus Christ (1 Peter 1:7).
In 1 Peter 1:6–9, the writer tells his readers to rejoice even while they are temporarily distressed by many kinds of trials. These hardships are not meaningless: they test and show the genuineness of their faith, which is portrayed as more valuable than gold refined by fire. This unit sits inside the opening part of the letter where the writer blesses God for giving his people a “living hope” and speaks about an inheritance kept safe for them (1:3–5). Verse 6 (“In this you rejoice”) points back to that hope as the reason joy is possible now.
This paragraph holds together two realities that might seem incompatible: deep joy and real grief. The readers “rejoice,” yet they are also “grieved” by “various trials” for “a little while” (explicit). The joy is tied to what has already been said about God’s promised future (inference from the “in this” link to 1:3–5).
A careful answer keeps the immediate passage, the book's argument, and the whole-Bible storyline together, so the question is answered in context instead of as a detached idea.
Start with 1 Peter 1:6-7, then read the surrounding section so the answer stays connected to the passage's flow.
6Wherein you greatly rejoice, though now for a little while, if need be, you have been put to grief in various trials,
7that the proof of your faith, which is more precious than gold that perishes even though it is tested by fire, may be found to result in praise and glory and honor at the revelation of Jesus Christ --