In more detail
The formula is (final value − cost) / cost × 100. "Cost" should include every amount you put in, including fees, and "final value" any income received along the way, such as dividends or rent. ROI ignores time: 15% over one year and over ten years are very different, so convert to an annual figure with (1 + ROI)^(1/years) − 1, which is the CAGR. It also ignores risk and, unless you adjust for it, inflation and taxes.
Why it matters
ROI is the quickest way to compare outcomes, but comparing ROIs over different periods, or before and after costs, leads to wrong choices. A business case quoting ROI without a time frame tells you little.
Example
Putting in $10,000 and ending with $11,500 is a 15% ROI. Spread over 3 years it is 4.77% a year; over 10 years, 1.41% a year. With $100 of fees on the way in and $100 on the way out, the ROI drops to (11,400 − 10,100) / 10,100 = 12.87%.
Common confusion
ROI is a total over the whole holding period; CAGR and IRR are annual rates.