Your approach is fine.
A few alternatives you might consider:
- You can generate random centers using a single call to
RandomReal:
Graphics3D[{Red, Sphere[RandomReal[{0.1, 0.9}, {50, 3}], 0.1]},
PlotRange -> {0, 1}]

- You can transform
Cuboid[] and use it with RandomPoint as follows:
r = .1;
transformedCuboid = Cuboid[r {1, 1, 1}, (1 - r) {1, 1, 1}];
centers = RandomPoint[transformedCuboid, 30];
Graphics3D[{PointSize[Medium], Point@centers,
Opacity[.5, Red], Sphere[#, r] & /@ centers,
EdgeForm[Blue], FaceForm[], Cuboid[],
EdgeForm[Green], transformedCuboid}]
