RoIAlign turns a candidate region (RoI) on a feature map into a feature of fixed size by dividing it into a fixed number of bins, without ever rounding coordinates to integers, computing the values at a few points placed in each bin by bilinear interpolation, and aggregating them. Its role is the same as RoI pooling, but it has no misalignment from rounding. It has no learnable parameters.
He et al. proposed it in 2017 as a component of Mask R-CNN, which predicts pixel-level masks in addition to object boxes. RoI pooling, the standard in object detection until then, rounds the region's coordinates and the bin boundaries to the grid of the feature map. The paper pointed out that this misalignment has little effect on classification, which is robust to small translations, but has a large negative effect on predicting pixel-accurate masks.
The change is small; in the paper's words, it simply "uses instead of (rounding)". Even so, mask accuracy improved by 10โ50% in relative terms, and the gains were larger for metrics that evaluate localization more strictly.
The top figure compares it with RoI pooling on the same feature map and the same RoI. RoI pooling rounds the coordinates (1.25, 1.75) to (1, 2), so it takes the maxima over a 4ร4 cell area shifted from the true region (dashed line). RoIAlign uses (1.25, 1.75) as is, divides the true region into 2ร2 bins, places 4 points in each bin, interpolates their values, and outputs the average.

