I guess it is because foo() = rand((1.3, 1)) is not type stable, foo2() = rand((1.3, 1.0)) is and does not allocate.
Chairmarks.jl actually does show why BenchmarkTools.jl shows 0 allocations:
julia> @b foo()
21.483 ns (0.45 allocs: 7.233 bytes)
It’s rounding to 0.