From: https://uk.mathworks.com/matlabcentral/answers/1459909-installer-hang-when-installing-matlab-r2021b-as-root-on-ubuntu-20-04#comment_1759029
I have been advised by Matlab Support "This appears to be an issue with MATLAB R2021b under root not being able to access the X Server". Workaround is to run the following command:
xhost +SI:localuser:root