If dollars pay 5% and euros pay 3%, you cannot simply hold dollars and be better off, because the forward rate at which you sell them back is set to remove the advantage. The forward price of the higher-yielding currency is lower, by roughly the interest-rate-differential.
Parity holds tightly for short tenors in major currencies and breaks down where balance sheet is scarce, which is measured by the cross-currency-basis. See also uncovered-interest-parity, which does not hold.
Example: spot EUR/USD 1.0840, one-year dollar rate 5.0%, euro rate 3.0%. The one-year forward is 1.0840 x 1.03 / 1.05 = 1.0634. A dollar investor earns 2% more interest and loses about 1.9% on the currency leg.
Related: forward-points, covered-interest-arbitrage, uncovered-interest-parity, cross-currency-basis