I too used to think that Social Security payments were based on one’s earnings (not counting disability or survivor’s benefits). Not true, not exactly and not always. The year after I received a stock market windfall, my Social Security payments went way down.
Turns out they use the income reported to the IRS to make “adjustments” in the amount you receive. The formula is so complex that even with the written explanation of IRMMA and MAGI I could not follow it. Remember the adage “what the government giveth, the government can taketh away.”