Roll a die 60 times. If it is fair, each face should come up about 10 times, but random variation means some faces get 8 and others 13. Suppose you see 8, 12, 11, 7, 13 and 9. Is that much unevenness normal? For each face, take the gap from expected, square it so gaps above and below both count, and divide by the expected count: 10(8−10)2=0.4, and so on. The six pieces are 0.4, 0.4, 0.1, 0.9, 0.9 and 0.1, which add to χ2=2.8.
Dividing by the expected count scales each gap by how big it ought to be: missing by 5 when you expected 10 is a large miss, while missing by 5 when you expected 1,000 is tiny. Then compare χ2 with its distribution when H0 (a fair die) is true. With 6 categories there are df=6−1=5 degrees of freedom and the 5% cutoff is about 11.07. A value of 2.8 is far below it, so this unevenness is ordinary for a fair die.
The same idea tests two-way tables. To ask whether favorite sport depends on grade, compute each cell's expected count assuming independence, grand totalrow total×column total, add E(O−E)2 over every cell, and use df=(r−1)(c−1).
Chi-square needs raw counts. If the data are measurements like test scores and the question is whether two means differ, use a two-sample t-test. And never feed it percentages: 30% of 10 people and 30% of 1,000 people carry very different amounts of evidence, which only the counts reveal.
Think of it like this. The chi-square statistic is a surprise score for a tally sheet. Each category adds its own surprise, the squared miss scaled by what was expected, and the total says how far the whole sheet strays from the prediction. Like any score, it means something only next to what chance alone usually produces, which the degrees of freedom pin down.
Core idea. The chi-square test sums squared gaps between observed and expected category counts to test independence or goodness of fit.